﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Diagnostics;
using CocosDenshion;
using cocos2d;

namespace Meteorite
{

    public class ShieldShip : Object
    {
        public ShieldShip(Model model)
            :base(model)
        {
        }

        public override void Update(GameTime gameTime)
        {
            world = Meteorite.ship.World;
            //base.Update(gameTime);
        }

        public override void Draw(Matrix View, Matrix Projection)
        {
            GraphicsDevice device = Meteorite.game.GraphicsDevice;
            BlendState backup = device.BlendState;
            device.BlendState = BlendState.AlphaBlend;

            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //effect.EnableDefaultLighting();           
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    effect.View = View;
                    effect.Projection = Projection;

                    effect.DirectionalLight0.Enabled = true;
                    // Please refer to the sample doc
                    effect.DirectionalLight0.Direction = Vector3.Backward; //Meteorite.ship.world.Forward;
                    effect.DirectionalLight0.DiffuseColor = Color.White.ToVector3();
                    Color col = new Color(100,100,255,100);
                    //effect.DiffuseColor = col.ToVector3();
                    effect.Alpha = 1.0f;
                    effect.FogColor = Color.WhiteSmoke.ToVector3();
                    //effect.DiffuseColor = Color.WhiteSmoke.ToVector3();

                }
                mesh.Draw();
            }
            device.BlendState = backup;
        }
    }
}

